var child;
var isRed;
/**
 * layui主体代码
 */
layui.use(['form', 'laydate','layer'], function () {
    var form = layui.form,
        layer = layui.layer,
        $ = layui.$,
        laydate = layui.laydate;

    /**
     * 监听提交
     */
    form.on('submit(saveBtn)', function (result) {
        child = result.field;
        let data = result.field;
        let updateid = $("#id").val();
        let studentId = $("#studentId").val();

        let index=  layer.msg('稍等一下', {
            icon: 16
            ,shade: 0.01,
            time : false,
        });
        $.ajaxSettings.async = true;
        $.post("society-for/updateScore",{
            studentId: studentId,
            id:updateid,
            applyState:data.applyState,
            computerExam:data.computerExam,
            interView:data.interView,
            penExam: data.penExam

        },function (result) {

            if (result.success == true) {
                layer.close(index);
                layer.open({
                    type: 1
                    ,content: '<div style="padding: 20px 100px;">'+ '成功' +'</div>'
                    ,btn: '确定'
                    ,yes: function(){
                        layer.closeAll();
                    }
                });
                close(result)
            }else {
                layer.close(index);
                layer.open({
                    type: 1
                    ,content: '<div style="padding: 20px 100px;">'+ '录入失败' +'</div>'
                    ,btn: '确定'
                    ,yes: function(){
                        layer.closeAll();
                    }
                });
        close(result);
            }

        })

        return false;
    });

});
/**
 * 子向父传值方法
 * @param result
 */
function close(result) {
    console.log(result)
    parent.parentPage(result, child);
    var index = parent.layer.getFrameIndex(window.name);
    parent.layer.close(index);
}